﻿#include "controlwidget.h"
#include "ui_controlwidget.h"
#include <QPoint>
#include "screen.h"
#include <QDebug>
#include <QApplication>

#define BUTTON_SIZE 24

ControlWidget::ControlWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::ControlWidget)
{
    this->setAttribute(Qt::WA_TranslucentBackground);
    this->setWindowFlags(Qt::FramelessWindowHint);

    ui->setupUi(this);
    ui->faceBtn->setVisible(false);
    ui->forwardBtn->setVisible(false);
    ui->clipBtn->setVisible(false);

    ui->returneditBtn->setEnabled(false);
}

//撤销截图按钮
void ControlWidget::on_cancelBtn_clicked()
{
    emit cancel();
}

//保存截图按钮
void ControlWidget::on_saveBtn_clicked()
{
    emit save();
}

//完成按钮将截图保存到剪贴板
void ControlWidget::on_finishBtn_clicked()
{
    emit finish();
}

ControlWidget::~ControlWidget()
{
    delete ui;
}

void ControlWidget::setDpi(int dp)
{
    ui->rectangleBtn->setFixedSize(QSize(BUTTON_SIZE * dp,BUTTON_SIZE * dp));
    ui->drawRoundBtn->setFixedSize(QSize(BUTTON_SIZE * dp,BUTTON_SIZE * dp));
    ui->arrowBtn->setFixedSize(QSize(BUTTON_SIZE * dp,BUTTON_SIZE * dp));
    ui->textEditBtn->setFixedSize(QSize(BUTTON_SIZE * dp,BUTTON_SIZE * dp));
    ui->drawLineBtn->setFixedSize(QSize(BUTTON_SIZE * dp,BUTTON_SIZE * dp));
    ui->mosaicBtn->setFixedSize(QSize(BUTTON_SIZE * dp,BUTTON_SIZE * dp));
    ui->returneditBtn->setFixedSize(QSize(BUTTON_SIZE * dp,BUTTON_SIZE * dp));
    ui->saveBtn->setFixedSize(QSize(BUTTON_SIZE * dp,BUTTON_SIZE * dp));
    ui->cancelBtn->setFixedSize(QSize(BUTTON_SIZE * dp,BUTTON_SIZE * dp));
    ui->finishBtn->setFixedSize(QSize(BUTTON_SIZE * dp,BUTTON_SIZE * dp));
    ui->faceBtn->setFixedSize(QSize(BUTTON_SIZE * dp,BUTTON_SIZE * dp));
    ui->clipBtn->setFixedSize(QSize(BUTTON_SIZE * dp,BUTTON_SIZE * dp));
    ui->forwardBtn->setFixedSize(QSize(BUTTON_SIZE * dp,BUTTON_SIZE * dp));

    ui->frame->setFixedWidth(dp);
}

void ControlWidget::setCanClip(bool clip)
{
    ui->clipBtn->setVisible(clip);
}

void ControlWidget::on_drawLineBtn_clicked()
{
    emit drawLine();
}

void ControlWidget::on_faceBtn_clicked()
{
    emit drawFace();
}

void ControlWidget::on_clipBtn_clicked()
{
    emit clip();
}

void ControlWidget::on_forwardBtn_clicked()
{
    emit forward();
}

void ControlWidget::setReturnEnabled(bool isEnabled)
{
    ui->returneditBtn->setEnabled(isEnabled);
}

void ControlWidget::on_textEditBtn_clicked()
{
    emit drawText();
}

void ControlWidget::on_rectangleBtn_clicked()
{
    emit drawRect();
}

void ControlWidget::on_drawRoundBtn_clicked()
{
    emit drawRound();
}

void ControlWidget::on_arrowBtn_clicked()
{
    emit drawArrow();
}

void ControlWidget::on_mosaicBtn_clicked()
{
    emit drawMosaic();
}

void ControlWidget::on_returneditBtn_clicked()
{
    emit undo();
}

void ControlWidget::on_arrow2Btn_clicked()
{
    emit drawArrow2();
}
